package cn.jofei.client.core;

import cn.jofei.client.netty.job.ReConnectJob;
import cn.jofei.common.thread.CommonEventLoop;
import cn.jofei.common.thread.ScheduledJob;
import cn.jofei.core.starter.AppFunctionStarter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.annotation.Annotation;

/**
 * PortListenerStarter
 *
 * @author Jofei Bao
 * @version ngbao v1.0.2
 * @date 2022/8/30 15:48
 */
public class NettyClientStartFunction implements AppFunctionStarter {
    /**
     * 启动任务
     */
    private static final ScheduledJob RETRY_JOB = new ReConnectJob();

    /**
     * 取消定时器
     */
    public static void cancel() {
        RETRY_JOB.cancel();
    }

    /**
     * 重试
     */
    public static void startJob() {
        CommonEventLoop.scheduled(RETRY_JOB, 5);
    }

    @Override
    public void beforeInject(Object o) {
    }

    @Override
    public void afterInject(Object o) {

    }

    @Override
    public void start() {
        startJob();
    }
}
